/*
 * @Author: wuqingchun
 * @Date: 2024-07-30 19:45:43
 * @Description: 大顶堆实现
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-07-30 19:54:22
 */
#ifndef __MAX_HEAP_H__
#define __MAX_HEAP_H__

#include <stddef.h>

typedef int (*MAXHEAP_CMP_NODE_PF)(void* pNode1, void* pNode2);

typedef struct tagMAXHEAP
{
    void** ppNodes;
    size_t ulCapacity;          // 空间大小
    size_t ulSize;              // 有效节点个数
    MAXHEAP_CMP_NODE_PF pfCmp;  // 节点大小比较函数
}MAX_HEAP_S;

int MAXHEAP_Init(MAX_HEAP_S* pstMaxHeap, size_t ulInitCapacity, MAXHEAP_CMP_NODE_PF pfCmp);
void MAXHEAP_Fini(MAX_HEAP_S* pstMaxHeap);
int MAXHEAP_Push(MAX_HEAP_S* pstMaxHeap, void* pNode);
void* MAXHEAP_Pop(MAX_HEAP_S* pstMaxHeap);

#endif //__MAX_HEAP_H__